package com.example.a12;

//import java.lang.reflect.Method;

public class Application13 {
    interface Foo {
        void foo();
        int bar();
    }

    static class Target implements Foo{
        @Override
        public void foo() {
            System.out.println("target foo");
        }

        @Override
        public int bar() {
            System.out.println("target bar");
            return 100;
        }
    }

/*
    interface InvocationHandler {
        Object invoke(Object proxy, Method method, Object[] args) throws Throwable;
    }
*/

    public static void main(String[] args) {
        Foo proxy = new $Proxy0((proxy1, method, args1) -> {
            // 1.功能增强
            System.out.println("before");

            // 2.调用目标
//            new A13.Target().foo();
            return method.invoke(new Target(), args1);
        });
        proxy.foo();
        proxy.bar();
    }
}
